package com.ruoyi.wwc.mq.listener;

import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.wwc.orders.domain.Orders;
import com.ruoyi.wwc.orders.service.IOrdersService;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class OrderListener {
    @Autowired
    private IOrdersService ordersService;
    //监听死信队列
    @RabbitListener(queues = "dead_queue")
    public void Listener(Orders orders){
        System.out.println("监听到死信队列消息："+orders);
        System.out.println(666);
        Orders orders1 = ordersService.selectOrdersById(orders.getId());
        if (orders1.getStatus()==0){
            orders1.setStatus(3L);
//            int j = 1/0;
            int i = ordersService.updateOrders(orders1);
            System.out.println("订单已过期");
        }
    }
}
